package algotrader.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class ConnectionFactory {
	private static Connection con;
	
	public static Connection getConnection() {
		try {
			if (con == null || con.isClosed()) {
				synchronized (ConnectionFactory.class) {
					Class.forName("org.postgresql.Driver");
					String url = "jdbc:postgresql://localhost/algotrader";
					Properties props = new Properties();
					props.setProperty("user", "postgres");
					props.setProperty("password", "@souzasecurities123");
					con = DriverManager.getConnection(url, props);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return con;
	}

}
